<template>  
  <view>
    
    <my-userinfo :username="username" :avatar="avatar"></my-userinfo>
  </view>
</template>  
  
<script>  
import{getUserDetail}from'../../api/person.js'
  import{mapMutations} from 'vuex'
  import{mapState} from 'vuex'
export default {  
  data() {  
    return {  
      username: '',
      avatar: '',
      userDetail: {}
  }; 
},
onShow(){
  this.username = JSON.parse(uni.getStorageSync('userinfo')).username
  this.avatar = JSON.parse(uni.getStorageSync('userinfo')).file
  console.log(this.username);
  console.log(this.avatar);
      console.log('返回了页面');
    },
    created(){
      this.getUserDetail()
    },
    computed:{
      ...mapState('User',['userinfo'])
    },
    methods:{
      ...mapMutations('User',['updateUserInfo']),
      async getUserDetail(){
        const {data:{data:data}} = await getUserDetail()
        console.log(data);
        this.userDetail = data
        this.updateUserInfo(this.userDetail)
        this.username = JSON.parse(uni.getStorageSync('userinfo')).username 
        this.avatar = JSON.parse(uni.getStorageSync('userinfo')).avatar
      },
    }
  }
</script>  
  
<style lang="scss">  

</style>